﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:Avalon.Windows.Controls"
    xmlns:conv="clr-namespace:Avalon.Windows.Converters"
    xmlns:fx="clr-namespace:Avalon.Windows.Media.Effects"
    xmlns:util="clr-namespace:Avalon.Windows.Utility">

    <!--## InlineModalDialog Style ##-->

    <Style x:Key="ShadowBorder"
           TargetType="controls:NineGridBorder">
        <Setter Property="Padding"
                Value="16" />
        <Setter Property="Image"
                Value="/AvalonLibrary;component/Images/DropShadow.png" />
        <Setter Property="ImageMargin"
                Value="16" />
    </Style>

    <Style TargetType="controls:InlineModalDialog">

        <Setter Property="HorizontalAlignment"
                Value="Center" />
        <Setter Property="VerticalAlignment"
                Value="Center" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ContentControl">
                    <controls:NineGridBorder Style="{StaticResource ShadowBorder}">
                        <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Content="{TemplateBinding Content}" />
                    </controls:NineGridBorder>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <Setter Property="RenderTransformOrigin"
                Value=".5,.5" />
        <Setter Property="RenderTransform">
            <Setter.Value>
                <ScaleTransform ScaleX="1"
                                ScaleY="1" />
            </Setter.Value>
        </Setter>

        <Setter Property="DialogIntroAnimation">
            <Setter.Value>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetProperty="(FrameworkElement.Opacity)"
                                     From="0"
                                     Duration="0:0:0.15" />
                    <DoubleAnimation BeginTime="0:0:0"
                                     Storyboard.TargetProperty="RenderTransform.ScaleX"
                                     From="0"
                                     DecelerationRatio="1"
                                     Duration="0:0:0.25" />
                    <DoubleAnimation BeginTime="0:0:0"
                                     Storyboard.TargetProperty="RenderTransform.ScaleY"
                                     From="0"
                                     DecelerationRatio="1"
                                     Duration="0:0:0.25" />
                </Storyboard>
            </Setter.Value>
        </Setter>

        <Setter Property="DialogOutroAnimation">
            <Setter.Value>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetProperty="(FrameworkElement.Opacity)"
                                     To="0"
                                     Duration="0:0:0.15" />
                </Storyboard>
            </Setter.Value>
        </Setter>

    </Style>
    
    <!--## CommandLink Style ##-->

    <Style TargetType="controls:CommandLink">
        <Setter Property="Padding" Value="5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:CommandLink">
                    <Border Name="Border" CornerRadius="3" BorderBrush="Transparent" BorderThickness="1" SnapsToDevicePixels="True">
                        <Border Name="InnerBorder" CornerRadius="2" BorderBrush="Transparent" BorderThickness="1" SnapsToDevicePixels="True" Padding="{TemplateBinding Padding}">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0,1">
                                    <GradientStop Offset="0" />
                                    <GradientStop Offset="0.05" />
                                    <GradientStop Offset="0.05" />
                                    <GradientStop Offset="1" />
                                </LinearGradientBrush>
                            </Border.Background>
                            <DockPanel>
                                <Path Name="Icon" DockPanel.Dock="Left" Width="14" Height="14"
                                    Stroke="White" StrokeThickness="1" Stretch="Fill"
                                    VerticalAlignment="Top" Margin="0,5,10,0" SnapsToDevicePixels="True"
                                    Data="M331.42534,14.87641C341.09201,22.87641 354.56757,35.745318 358.64534,39.865195 360.457,43.937551 362.38157,47.232932 358.97329,52.706642 353.91714,57.832373 342.05975,69.015017 333.39308,77.34835 323.50061,82.210866 316.72712,70.840992 319.61911,65.201028 322.00683,62.952481 326.73716,60.149844 332.73716,55.483177L302.89355,55.483171C295.91117,49.0204,297.09731,43.542511,304,38L332,38C332,38 318.96319,26.3296 318.96319,26.3296 321.06197,16.644267 325.10076,15.700739 331.42534,14.87641Z">
                                    <Path.Fill>
                                        <LinearGradientBrush EndPoint="0,1">
                                            <GradientStop Color="#038D00" Offset="0" />
                                            <GradientStop Color="#00DB39" Offset="1" />
                                        </LinearGradientBrush>
                                    </Path.Fill>
                                </Path>
                                <ContentPresenter RecognizesAccessKey="True" Name="Content" TextBlock.Foreground="#003399" />
                            </DockPanel>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsIconVisible" Value="False">
                            <Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsDefaulted" Value="True" />
                                <Condition Property="IsPressed" Value="False" />
                                <Condition Property="IsMouseOver" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Border" Property="BorderBrush" Value="#66e0ff" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsKeyboardFocused" Value="True" />
                                <Condition Property="IsPressed" Value="False" />
                                <Condition Property="IsMouseOver" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Border" Property="BorderBrush" Value="#66e0ff" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsDefaulted" Value="True" />
                                <Condition Property="IsMouseOver" Value="True" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.25" To="#074ae5" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#66e0ff" To="#c6c6c6" Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="White" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#ffffff" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[2].Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#f4f4f4" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[3].Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#07AC03" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Fill.GradientStops[0].Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#40F76F" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Fill.GradientStops[1].Color" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.25" From="#074ae5" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#c6c6c6" To="#66e0ff" Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="White" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#ffffff" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[2].Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#f4f4f4" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[3].Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#07AC03" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Fill.GradientStops[0].Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#40F76F" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Fill.GradientStops[1].Color" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsKeyboardFocused" Value="True" />
                                <Condition Property="IsMouseOver" Value="True" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.25" To="#074ae5" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#66e0ff" To="#c6c6c6" Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="White" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#ffffff" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[2].Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#f4f4f4" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[3].Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#07AC03" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Fill.GradientStops[0].Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#40F76F" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Fill.GradientStops[1].Color" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.25" From="#074ae5" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#c6c6c6" To="#66e0ff" Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="White" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#ffffff" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[2].Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#f4f4f4" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[3].Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#07AC03" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Fill.GradientStops[0].Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#40F76F" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Fill.GradientStops[1].Color" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsDefaulted" Value="False" />
                                <Condition Property="IsKeyboardFocused" Value="False" />
                                <Condition Property="IsMouseOver" Value="True" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.25" To="#074ae5" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#c6c6c6" Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="White" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#ffffff" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[2].Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#f4f4f4" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[3].Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#07AC03" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Fill.GradientStops[0].Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#40F76F" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Fill.GradientStops[1].Color" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.25" From="#074ae5" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#c6c6c6" Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="White" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#ffffff" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[2].Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#f4f4f4" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[3].Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#07AC03" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Fill.GradientStops[0].Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#40F76F" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Fill.GradientStops[1].Color" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.25" To="#a8a8a8" Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#e8e9e9" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#dadada" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[0].Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#f0f1f1" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[1].Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#f0f1f1" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[2].Color" />
                                        <ColorAnimation Duration="0:0:0.25" To="#f0f1f1" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[3].Color" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.25" From="#a8a8a8" Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#e8e9e9" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="BorderBrush.Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#dadada" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[0].Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#f0f1f1" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[1].Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#f0f1f1" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[2].Color" />
                                        <ColorAnimation Duration="0:0:0.25" From="#f0f1f1" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background.GradientStops[3].Color" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--## Expander Toggle Button Style (Aero) ##-->

    <LinearGradientBrush x:Key="ExpanderArrowFill" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="White" Offset="0"/>
        <GradientStop Color="#FFBFBFBF" Offset="0.5"/>
        <GradientStop Color="#FF878787" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="ExpanderArrowHoverFill" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FFF0F8FE" Offset="0"/>
        <GradientStop Color="#FFE0F3FE" Offset="0.3"/>
        <GradientStop Color="#FF6FA7C5" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="ExpanderArrowPressedFill" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FFDCF0FA" Offset="0"/>
        <GradientStop Color="#FFC5E6F7" Offset="0.2"/>
        <GradientStop Color="#FF5690D0" Offset="1"/>
    </LinearGradientBrush>

    <Style x:Key="ExpanderDownHeaderStyle" TargetType="ToggleButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="19"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Ellipse x:Name="circle" Width="19" Height="19" Stroke="DarkGray" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="{StaticResource ExpanderArrowFill}"/>
                            <Path Grid.Column="0" x:Name="arrow" HorizontalAlignment="Center" VerticalAlignment="Center" Stroke="#666" StrokeThickness="2" SnapsToDevicePixels="false" Data="M 1,1.5 L 4.5,5 L 8,1.5"/>
                            <ContentPresenter Grid.Column="1" Margin="4,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" SnapsToDevicePixels="True" RecognizesAccessKey="True"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="Data" Value="M 1,4.5  L 4.5,1  L 8,4.5" TargetName="arrow"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Stroke" Value="#FF3C7FB1" TargetName="circle"/>
                            <Setter Property="Fill" Value="{StaticResource ExpanderArrowHoverFill}" TargetName="circle"/>
                            <Setter Property="Stroke" Value="#222" TargetName="arrow"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Stroke" Value="#FF526C7B" TargetName="circle"/>
                            <Setter Property="StrokeThickness" Value="1.5" TargetName="circle"/>
                            <Setter Property="Fill" Value="{StaticResource ExpanderArrowPressedFill}" TargetName="circle"/>
                            <Setter Property="Stroke" Value="#FF003366" TargetName="arrow"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--## Buttons and Button Lists ##-->

    <Style x:Key="ButtonList" TargetType="ItemsControl">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ButtonItem" TargetType="Button">
        <Setter Property="Margin" Value="7,0,0,0" />
        <Setter Property="MinWidth" Value="65" />
        <Setter Property="Padding" Value="7,0,7,0" />
        <Setter Property="IsDefault" Value="{Binding Content.IsDefault}" />
        <Style.Resources>
            <DataTemplate DataType="{x:Type controls:TaskDialogButtonData}">
                <ContentPresenter RecognizesAccessKey="True" Content="{Binding Header, Converter={conv:EnumToStringConverter}}" />
            </DataTemplate>
        </Style.Resources>
    </Style>

    <Style x:Key="CommandLinkItem" TargetType="controls:CommandLink">
        <Setter Property="Margin" Value="0" />
        <Setter Property="IsDefault" Value="{Binding Content.IsDefault}" />
        <Style.Resources>
            <DataTemplate DataType="{x:Type controls:TaskDialogButtonData}">
                <DockPanel>
                    <ContentPresenter RecognizesAccessKey="True" DockPanel.Dock="Top" TextBlock.FontSize="16" Content="{Binding Header}" />
                    <ContentPresenter Content="{Binding Content}" TextBlock.Foreground="Black" />
                </DockPanel>
            </DataTemplate>
        </Style.Resources>
    </Style>

    <Style x:Key="RadioButtonItem" TargetType="RadioButton">
        <Setter Property="Margin" Value="7,0,0,7" />
        <Setter Property="Padding" Value="7,0,7,0" />
        <Setter Property="GroupName" Value="TaskDialogRadioButtons" />
        <Setter Property="IsChecked" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Selector.IsSelected)}" />
    </Style>

    <!--## Converters ##-->

    <conv:EnumFlagsConverter x:Key="EnumFlagsConverter" />
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

    <!--## TaskDialog Style ##-->

    <ControlTemplate x:Key="FooterExpansionTaskDialog" TargetType="controls:TaskDialog">
        <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
            <DockPanel>
                <!-- Expansion Footer -->
                <Border Name="ExpansionBorder" DockPanel.Dock="Bottom" util:AnimationHelpers.HeightPercentage="0"
                                    Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
                                    BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"
                                    BorderThickness="0,1,0,0" Padding="10">
                    <ContentPresenter ContentSource="ExpansionContent">
                        <ContentPresenter.Resources>
                            <Style TargetType="TextBlock">
                                <Setter Property="TextWrapping" Value="Wrap" />
                            </Style>
                        </ContentPresenter.Resources>
                    </ContentPresenter>
                </Border>
                <!-- Footer -->
                <Border Name="Footer" DockPanel.Dock="Bottom" Visibility="{TemplateBinding ShowFooter, Converter={StaticResource BooleanToVisibilityConverter}}"
                                    Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
                                    BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"
                                    BorderThickness="0,1,0,0" Padding="10">
                    <DockPanel>
                        <Image Name="FooterIcon" DockPanel.Dock="Left" HorizontalAlignment="Center" VerticalAlignment="Top" Width="16" Height="16" Source="{TemplateBinding FooterIcon}" Margin="2,0,8,0" />
                        <ContentPresenter ContentSource="Footer">
                            <ContentPresenter.Resources>
                                <Style TargetType="TextBlock">
                                    <Setter Property="TextWrapping" Value="Wrap" />
                                </Style>
                            </ContentPresenter.Resources>
                        </ContentPresenter>
                    </DockPanel>
                </Border>
                <!-- Buttons, Verification and Expansion -->
                <Border Name="Bottom" DockPanel.Dock="Bottom"
                                    Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
                                    BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"
                                    BorderThickness="0,1,0,0" Padding="10">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <StackPanel>
                            <ToggleButton Name="Expansion" Style="{StaticResource ExpanderDownHeaderStyle}" HorizontalAlignment="Left" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsExpanded}">
                                <ContentPresenter ContentSource="ExpansionButtonContent" RecognizesAccessKey="True" />
                            </ToggleButton>
                            <CheckBox Visibility="{TemplateBinding ShowVerification, Converter={StaticResource BooleanToVisibilityConverter}}"
                                                  IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsVerificationChecked}" HorizontalAlignment="Left"
                                                  Margin="4,4,0,0">
                                <ContentPresenter ContentSource="Verification" RecognizesAccessKey="True" Margin="4,0,0,0">
                                    <ContentPresenter.Resources>
                                        <Style TargetType="TextBlock">
                                            <Setter Property="TextWrapping" Value="Wrap" />
                                        </Style>
                                    </ContentPresenter.Resources>
                                </ContentPresenter>
                            </CheckBox>
                        </StackPanel>
                        <controls:TypedItemsControl Name="PART_ButtonList" ItemContainerType="Button" Style="{StaticResource ButtonList}" Focusable="False"
                                                    Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Top"
                                                    ItemsSource="{TemplateBinding Buttons}"
                                                    ItemContainerStyle="{TemplateBinding ButtonContainerStyle}"
                                                    ItemContainerStyleSelector="{TemplateBinding ButtonContainerStyleSelector}"
                                                    ItemTemplate="{TemplateBinding ButtonTemplate}"
                                                    ItemTemplateSelector="{TemplateBinding ButtonTemplateSelector}" />
                    </Grid>
                </Border>
                <!-- Main Icon -->
                <Image Name="MainIcon" DockPanel.Dock="Left" HorizontalAlignment="Center" VerticalAlignment="Top" Width="32" Height="32" Source="{TemplateBinding MainIcon}" Margin="10,8,0,0" />
                <!-- Content, Progres Bar, Radio Buttons and Command Links -->
                <StackPanel Margin="14,10,10,10">
                    <!-- Header -->
                    <Border>
                        <ContentPresenter TextBlock.FontSize="16" TextBlock.Foreground="#003399" ContentSource="Header">
                            <ContentPresenter.Resources>
                                <Style TargetType="TextBlock">
                                    <Setter Property="TextWrapping" Value="Wrap" />
                                </Style>
                            </ContentPresenter.Resources>
                        </ContentPresenter>
                    </Border>
                    <!-- Content -->
                    <Border Margin="0,14,0,8">
                        <ContentPresenter>
                            <ContentPresenter.Resources>
                                <Style TargetType="TextBlock">
                                    <Setter Property="TextWrapping" Value="Wrap" />
                                </Style>
                            </ContentPresenter.Resources>
                        </ContentPresenter>
                    </Border>
                    <!-- Progress Bar -->
                    <ProgressBar Name="Progress" Margin="0,8,0,8" Height="16" IsIndeterminate="{TemplateBinding IsProgressIndeterminate}" Visibility="{TemplateBinding ShowProgressBar, Converter={StaticResource BooleanToVisibilityConverter}}" />
                    <!-- Radio Buttons -->
                    <controls:TypedListBox Name="PART_RadioButtonList" ItemContainerType="RadioButton" Margin="0,8,0,0" Focusable="False"
                                                ItemsSource="{TemplateBinding RadioButtons}" BorderThickness="0"
                                                ItemContainerStyle="{TemplateBinding RadioButtonContainerStyle}"
                                                ItemContainerStyleSelector="{TemplateBinding RadioButtonContainerStyleSelector}"
                                                ItemTemplate="{TemplateBinding RadioButtonTemplate}"
                                                ItemTemplateSelector="{TemplateBinding RadioButtonTemplateSelector}" />
                    <!-- Command Links -->
                    <controls:TypedItemsControl Name="PART_CommandLinkList" ItemContainerType="controls:CommandLink" Margin="0,8,0,0" Focusable="False"
                                                ItemsSource="{TemplateBinding CommandLinks}"
                                                ItemContainerStyle="{TemplateBinding CommandLinkContainerStyle}"
                                                ItemContainerStyleSelector="{TemplateBinding CommandLinkContainerStyleSelector}"
                                                ItemTemplate="{TemplateBinding CommandLinkTemplate}"
                                                ItemTemplateSelector="{TemplateBinding CommandLinkTemplateSelector}" />
                </StackPanel>
            </DockPanel>
        </Border>
        <ControlTemplate.Triggers>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Buttons.Count}" Value="0" />
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=ShowVerification}" Value="False" />
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=ExpansionPosition}" Value="None" />
                </MultiDataTrigger.Conditions>
                <Setter TargetName="Bottom" Property="Visibility" Value="Collapsed" />
            </MultiDataTrigger>
            <Trigger Property="ExpansionPosition" Value="None">
                <Setter TargetName="Expansion" Property="Visibility" Value="Collapsed" />
            </Trigger>
            <Trigger Property="IsExpanded" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <Int32Animation From="0" To="100" Duration="0:0:0.25" Storyboard.TargetProperty="(util:AnimationHelpers.HeightPercentage)" Storyboard.TargetName="ExpansionBorder" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <Int32Animation To="0" Duration="0:0:0.25" Storyboard.TargetProperty="(util:AnimationHelpers.HeightPercentage)" Storyboard.TargetName="ExpansionBorder" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.ExitActions>
            </Trigger>
            <Trigger Property="MainIcon" Value="{x:Null}">
                <Setter TargetName="MainIcon" Property="Visibility" Value="Collapsed" />
            </Trigger>
            <Trigger Property="FooterIcon" Value="{x:Null}">
                <Setter TargetName="FooterIcon" Property="Visibility" Value="Collapsed" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="HeaderExpansionTaskDialog" TargetType="controls:TaskDialog">
        <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
            <DockPanel>
                <!-- Footer -->
                <Border Name="Footer" DockPanel.Dock="Bottom" Visibility="{TemplateBinding ShowFooter, Converter={StaticResource BooleanToVisibilityConverter}}"
                                    Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
                                    BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"
                                    BorderThickness="0,1,0,0" Padding="10">
                    <DockPanel>
                        <Image Name="FooterIcon" DockPanel.Dock="Left" HorizontalAlignment="Center" VerticalAlignment="Top" Width="16" Height="16" Source="{TemplateBinding FooterIcon}" Margin="2,0,8,0" />
                        <ContentPresenter ContentSource="Footer">
                            <ContentPresenter.Resources>
                                <Style TargetType="TextBlock">
                                    <Setter Property="TextWrapping" Value="Wrap" />
                                </Style>
                            </ContentPresenter.Resources>
                        </ContentPresenter>
                    </DockPanel>
                </Border>
                <!-- Buttons, Verification and Expansion -->
                <Border Name="Bottom" DockPanel.Dock="Bottom"
                                    Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
                                    BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"
                                    BorderThickness="0,1,0,0" Padding="10">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <StackPanel>
                            <ToggleButton Name="Expansion" Style="{StaticResource ExpanderDownHeaderStyle}" HorizontalAlignment="Left" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsExpanded}">
                                <ContentPresenter ContentSource="ExpansionButtonContent" RecognizesAccessKey="True" />
                            </ToggleButton>
                            <CheckBox Visibility="{TemplateBinding ShowVerification, Converter={StaticResource BooleanToVisibilityConverter}}"
                                                  IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsVerificationChecked}" HorizontalAlignment="Left"
                                                  Margin="4,4,0,0">
                                <ContentPresenter ContentSource="Verification" RecognizesAccessKey="True" Margin="4,0,0,0">
                                    <ContentPresenter.Resources>
                                        <Style TargetType="TextBlock">
                                            <Setter Property="TextWrapping" Value="Wrap" />
                                        </Style>
                                    </ContentPresenter.Resources>
                                </ContentPresenter>
                            </CheckBox>
                        </StackPanel>
                        <controls:TypedItemsControl Name="PART_ButtonList" ItemContainerType="Button" Style="{StaticResource ButtonList}" Focusable="False"
                                                    Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Top"
                                                    ItemsSource="{TemplateBinding Buttons}"
                                                    ItemContainerStyle="{TemplateBinding ButtonContainerStyle}"
                                                    ItemContainerStyleSelector="{TemplateBinding ButtonContainerStyleSelector}"
                                                    ItemTemplate="{TemplateBinding ButtonTemplate}"
                                                    ItemTemplateSelector="{TemplateBinding ButtonTemplateSelector}" />
                    </Grid>
                </Border>
                <!-- Main Icon -->
                <Image Name="MainIcon" DockPanel.Dock="Left" HorizontalAlignment="Center" VerticalAlignment="Top" Width="32" Height="32" Source="{TemplateBinding MainIcon}" Margin="10,8,0,0" />
                <!-- Content, Progres Bar, Radio Buttons and Command Links -->
                <StackPanel Margin="14,10,10,10">
                    <!-- Header -->
                    <Border>
                        <ContentPresenter TextBlock.FontSize="16" TextBlock.Foreground="#003399" ContentSource="Header">
                            <ContentPresenter.Resources>
                                <Style TargetType="TextBlock">
                                    <Setter Property="TextWrapping" Value="Wrap" />
                                </Style>
                            </ContentPresenter.Resources>
                        </ContentPresenter>
                    </Border>
                    <!-- Content -->
                    <Border Margin="0,14,0,8">
                        <ContentPresenter>
                            <ContentPresenter.Resources>
                                <Style TargetType="TextBlock">
                                    <Setter Property="TextWrapping" Value="Wrap" />
                                </Style>
                            </ContentPresenter.Resources>
                        </ContentPresenter>
                    </Border>
                    <Border Name="ExpansionBorder" util:AnimationHelpers.HeightPercentage="0">
                        <ContentPresenter ContentSource="ExpansionContent">
                            <ContentPresenter.Resources>
                                <Style TargetType="TextBlock">
                                    <Setter Property="TextWrapping" Value="Wrap" />
                                </Style>
                            </ContentPresenter.Resources>
                        </ContentPresenter>
                    </Border>
                    <!-- Progress Bar -->
                    <ProgressBar Name="Progress" Margin="0,8,0,8" Height="16" IsIndeterminate="{TemplateBinding IsProgressIndeterminate}" Visibility="{TemplateBinding ShowProgressBar, Converter={StaticResource BooleanToVisibilityConverter}}" />
                    <!-- Radio Buttons -->
                    <controls:TypedListBox Name="PART_RadioButtonList" ItemContainerType="RadioButton" Margin="0,8,0,0" Focusable="False"
                                                ItemsSource="{TemplateBinding RadioButtons}" BorderThickness="0"
                                                ItemContainerStyle="{TemplateBinding RadioButtonContainerStyle}"
                                                ItemContainerStyleSelector="{TemplateBinding RadioButtonContainerStyleSelector}"
                                                ItemTemplate="{TemplateBinding RadioButtonTemplate}"
                                                ItemTemplateSelector="{TemplateBinding RadioButtonTemplateSelector}" />
                    <!-- Command Links -->
                    <controls:TypedItemsControl Name="PART_CommandLinkList" ItemContainerType="controls:CommandLink" Margin="0,8,0,0" Focusable="False"
                                                ItemsSource="{TemplateBinding CommandLinks}"
                                                ItemContainerStyle="{TemplateBinding CommandLinkContainerStyle}"
                                                ItemContainerStyleSelector="{TemplateBinding CommandLinkContainerStyleSelector}"
                                                ItemTemplate="{TemplateBinding CommandLinkTemplate}"
                                                ItemTemplateSelector="{TemplateBinding CommandLinkTemplateSelector}" />
                </StackPanel>
            </DockPanel>
        </Border>
        <ControlTemplate.Triggers>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Buttons.Count}" Value="0" />
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=ShowVerification}" Value="False" />
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=ExpansionPosition}" Value="None" />
                </MultiDataTrigger.Conditions>
                <Setter TargetName="Bottom" Property="Visibility" Value="Collapsed" />
            </MultiDataTrigger>
            <Trigger Property="ExpansionPosition" Value="None">
                <Setter TargetName="Expansion" Property="Visibility" Value="Collapsed" />
            </Trigger>
            <Trigger Property="IsExpanded" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <Int32Animation From="0" To="100" Duration="0:0:0.25" Storyboard.TargetProperty="(util:AnimationHelpers.HeightPercentage)" Storyboard.TargetName="ExpansionBorder" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <Int32Animation To="0" Duration="0:0:0.25" Storyboard.TargetProperty="(util:AnimationHelpers.HeightPercentage)" Storyboard.TargetName="ExpansionBorder" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.ExitActions>
            </Trigger>
            <Trigger Property="MainIcon" Value="{x:Null}">
                <Setter TargetName="MainIcon" Property="Visibility" Value="Collapsed" />
            </Trigger>
            <Trigger Property="FooterIcon" Value="{x:Null}">
                <Setter TargetName="FooterIcon" Property="Visibility" Value="Collapsed" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <controls:TaskDialogButtonTemplateSelector x:Key="TaskDialogButtonTemplateSelector" />

    <Style TargetType="controls:TaskDialog">
        <Setter Property="MinWidth" Value="360" />
        <Setter Property="MinHeight" Value="70" />
        <Setter Property="ButtonContainerStyle" Value="{StaticResource ButtonItem}" />
        <Setter Property="ButtonTemplateSelector" Value="{StaticResource TaskDialogButtonTemplateSelector}" />
        <Setter Property="CommandLinkContainerStyle" Value="{StaticResource CommandLinkItem}" />
        <Setter Property="CommandLinkTemplateSelector" Value="{StaticResource TaskDialogButtonTemplateSelector}" />
        <Setter Property="RadioButtonContainerStyle" Value="{StaticResource RadioButtonItem}" />
        <Setter Property="Template" Value="{StaticResource FooterExpansionTaskDialog}" />
        <Style.Triggers>
            <Trigger Property="ExpansionPosition" Value="Header">
                <Setter Property="Template" Value="{StaticResource HeaderExpansionTaskDialog}" />
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>
